/*

Summary:
ListBox class.

Remark:
None.

Version:
0.0.2

LastUpdatedDate:
2012-09-21

*/

#pragma once

#include <string>
#include "ControlWindow.h"
#include "..\..\Enum.h"



namespace Zaf {
namespace Mwl {
namespace __Internal {
	class WndProcPicker;
}


ZafEnum(SelectionMode, DWORD) {

	None = 0,
	Single = 1,
	MultiSimple = 2,
	MultiExtended = 3,
};


class ListBox : public ControlWindow {

public:
	ListBox();
	explicit ListBox(WORD id);
	virtual ~ListBox();

	bool IsAutoSort() const;
	void IsAutoSort(bool value);

	bool IsMultiColumn() const;
	void IsMultiColumn(bool value);

	bool AlwaysShowScrollbar() const;
	void AlwaysShowScrollbar(bool value);

	SelectionMode GetSelectionMode() const;
	void SetSelectionMode(SelectionMode value);

	int AddString(const wchar_t* value);
	int AddString(const std::wstring& value) { return AddString(value.c_str()); }

	int InsertString(const wchar_t* value, int pos);
	int InsertString(const std::wstring& value, int pos) { return InsertString(value.c_str(), pos); }

	int DeleteString(int index);

	int FindString(const wchar_t* value, int pos = -1) const;
	int FindString(const std::wstring& value, int pos = -1) const { return FindString(value.c_str(), pos); }

	int FindStringExactly(const wchar_t* value, int pos = -1) const;
	int FindStringExactly(const std::wstring& value, int pos = -1) const { return FindStringExactly(value.c_str(), pos); }

	int GetCount() const;
	int GetSelectedCount() const;

	int GetSelectedIndex() const;
	void SetSelectedIndex(int index);

	int SelectString(const wchar_t* value, int pos = -1);
	int SelectString(const std::wstring& value, int pos = -1) { return SelectString(value.c_str(), pos); }

	int GetSelectedIndices(int count, int* indices) const;

	bool GetSelectionState(int index) const;
	void SetSelectionState(int index, bool selected);

	std::wstring GetString(int index) const;

	void Clear();

protected:
	LRESULT DefWndProc(const WndMsg& msg);

private:
	HWND CreateConcreteWindow();
	void CommonConstructor();

	static const wchar_t* const ClassName;
	static __Internal::WndProcPicker ListBoxWndProc;
};



}
}